﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebService.Connect;
using System.Data.SqlClient;
using Model;
using System.Data;


namespace WebService.Datalayer
{
    public class DBMenuTypes
    {
        Database db = new Database();
        SqlParameter[] listParameter;

        /// <summary>
        /// SelectMenuTypesAll
        /// </summary>
        /// <returns></returns>
        public DataSet SelectMenuTypesAll()
        {
            return db.GetDataset("sp_SelectMenuTypesAll");
        }

        /// <summary>
        /// SelectMenuTypesByAndMenuTypeID
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public DataSet SelectMenuTypesByAndMenuTypeID(MenuTypes obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@MenuTypeID", obj.MenuTypeID),
            };
            return db.GetDataSetWithParameter("sp_SelectMenuTypesByAndMenuTypeID", listParameter);
        }

        /// <summary>
        /// DeleteMenuType
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int DeleteMenuType(MenuTypes obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@MenuTypeID", obj.MenuTypeID),
            };
            return db.ExcuteQueryWithParamater("sp_DeleteMenuType", listParameter);
        }

        /// <summary>
        /// InsertMenuType
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int InsertMenuType(MenuTypes obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@MenuTypeID", obj.MenuTypeID),
                new SqlParameter("@MenuTypeName", obj.MenuTypeName),
                new SqlParameter("@Description", obj.Description),
                new SqlParameter("@IsDeleted", obj.IsDeleted),
            };
            return db.ExcuteQueryWithParamater("sp_InsertMenuType", listParameter);
        }

        /// <summary>
        /// UpdateMenuType
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int UpdateMenuType(MenuTypes obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@MenuTypeName", obj.MenuTypeName),
                new SqlParameter("@Description", obj.Description),
                new SqlParameter("@IsDeleted", obj.IsDeleted),
                new SqlParameter("@MenuTypeID", obj.MenuTypeID),
            };
            return db.ExcuteQueryWithParamater("sp_UpdateMenuType", listParameter);
        }

    }
}